home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / mntdoc01.zoo / mintdoc / cat2 / psignal.nr < prev    next >
Encoding:
Text File  |  1993-03-03  |  4.4 KB  |  133 lines

  1.  
  2.  
  3.  
  4. Psignal(2)                 May 1, 1992                 Psignal(2)
  5.  
  6.  
  7. N✓NA✓AM✓ME✓E
  8.        Psignal - change the way a signal is handled
  9.  
  10. S✓SY✓YN✓NO✓OP✓PS✓SI✓IS✓S
  11.        #include <signal.h>
  12.  
  13.        LONG Psignal(WORD sig, LONG handler);
  14.  
  15. D✓DE✓ES✓SC✓CR✓RI✓IP✓PT✓TI✓IO✓ON✓N
  16.        _✓P_✓s_✓i_✓g_✓n_✓a_✓l  changes  the  handling of the signal indicated by
  17.        _✓s_✓i_✓g (which must be between 1 and  31  inclusive;  symbolic
  18.        constants for symbols are defined in the file signal.h).
  19.  
  20.        If  _✓h_✓a_✓n_✓d_✓l_✓e_✓r  is  SIG_DFL,  then the default action for the
  21.        signal will occur when the signal is delivered to the pro-
  22.        cess.
  23.  
  24.        If  _✓h_✓a_✓n_✓d_✓l_✓e_✓r is SIG_IGN, then the signal will be ignored by
  25.        the process, and delivery  of  the  signal  will  have  no
  26.        noticeable  effect  (in  particular,  the  signal will not
  27.        interrupt the _✓P_✓a_✓u_✓s_✓e or _✓P_✓s_✓i_✓g_✓p_✓a_✓u_✓s_✓e system calls,  q.v.).  If
  28.        the  signal is pending at the time of the _✓P_✓s_✓i_✓g_✓n_✓a_✓l call, it
  29.        is discarded.
  30.  
  31.        If _✓h_✓a_✓n_✓d_✓l_✓e_✓r is some other value, it is assumed  to  be  the
  32.        address  of  a  user function that will be called when the
  33.        signal is delivered to the process. The user  function  is
  34.        called  with a single LONG argument on the stack, which is
  35.        the number of the signal being delivered (this is done  so
  36.        that  processes  may  use the same handler for a number of
  37.        different signals). While the signal is being handled,  it
  38.        is  blocked from delivery; thus, signal handling is "reli-
  39.        able" (unlike Version 7 and early System V Unix  implemen-
  40.        tations, in which delivery of a second signal while it was
  41.        being handled could kill the process). Note  that,  unlike
  42.        in some versions of Unix, the signal handling is not reset
  43.        to the default action before the  handler  is  called;  it
  44.        remains set to the given signal handler.
  45.  
  46.        The  signal handler must either return (via a normal 680x0
  47.        rts instruction) or call the  _✓P_✓s_✓i_✓g_✓r_✓e_✓t_✓u_✓r_✓n  system  call  to
  48.        indicate  when signal handling is complete; in both cases,
  49.        the signal will be  unblocked.  Psigreturn  also  performs
  50.        some  internal clean-up of the kernel stack that is neces-
  51.        sary if the signal handler is not planning to return  (for
  52.        example, if the C longjmp() function is to be used to con-
  53.        tinue execution at another point in the program).
  54.  
  55.        Signal handlers may make any GEMDOS, BIOS, or XBIOS system
  56.        calls freely.  GEM AES and VDI calls should not be made in
  57.        a signal handler.
  58.  
  59.        Note that calling _✓P_✓s_✓i_✓g_✓n_✓a_✓l to change behavior of  a  signal
  60.        has  the  side  effect  of  unmasking that signal, so that
  61.  
  62.  
  63.  
  64. Version 0.95         MiNT Programmer's Manual                   1
  65.  
  66.  
  67.  
  68.  
  69.  
  70. Psignal(2)                 May 1, 1992                 Psignal(2)
  71.  
  72.  
  73.        delivery is possible. This is done so that processes  may,
  74.        while handling a signal, reset the behavior and send them-
  75.        selves another instance of  the  signal,  for  example  in
  76.        order  to  suspend themselves while handling a job control
  77.        signal.  Signal handling is  preserved  across  _✓P_✓f_✓o_✓r_✓k  and
  78.        _✓P_✓v_✓f_✓o_✓r_✓k  calls.  Signals that are ignored by the parent are
  79.        also ignored by the child after a _✓P_✓e_✓x_✓e_✓c call; signals that
  80.        were  being caught for handling in a function are reset in
  81.        the child to the default behavior.
  82.  
  83. R✓RE✓ET✓TU✓UR✓RN✓NS✓S
  84.        The old value of the signal handler on success; this  will
  85.        be either SIG_DFL, SIG_IGN, or a function address.
  86.  
  87.        ERANGE if _✓s_✓i_✓g is not a legal signal.
  88.  
  89.        EACCDN if the signal may not be caught by the user
  90.  
  91. S✓SE✓EE✓E A✓AL✓LS✓SO✓O
  92.        _✓P_✓k_✓i_✓l_✓l(2), _✓P_✓s_✓i_✓g_✓a_✓c_✓t_✓i_✓o_✓n(2), _✓P_✓s_✓i_✓g_✓b_✓l_✓o_✓c_✓k(2), _✓P_✓s_✓i_✓g_✓r_✓e_✓t_✓u_✓r_✓n(2)
  93.  
  94. B✓BU✓UG✓GS✓S
  95.        Signal handling can be nested only a small (around 3) num-
  96.        ber of times, i.e. if 4 signals are delivered  to  a  pro-
  97.        cess,  and the process has established handlers for all 4,
  98.        and none of the handlers has returned  or  called  _✓P_✓s_✓i_✓g_✓r_✓e_✓-
  99.        _✓t_✓u_✓r_✓n,
  100.         then  there  is  a  very  good chance of a stack overflow
  101.        killing the process off. In practice, this is unlikely  to
  102.        happen.
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130. Version 0.95         MiNT Programmer's Manual                   2
  131.  
  132.  
  133.